package com.mt.roll.wms.controller;

import com.mt.roll.core.base.BaseController;
import com.mt.roll.core.constants.CommonConstant;
import com.mt.roll.core.params.IdParam;
import com.mt.roll.core.validator.groups.AddGroup;
import com.mt.roll.core.validator.groups.PageGroup;
import com.mt.roll.core.validator.groups.UpdateGroup;
import com.mt.roll.core.vo.IdVo;
import com.mt.roll.core.vo.PageVo;
import com.mt.roll.core.vo.R;
import com.mt.roll.wms.params.*;
import com.mt.roll.wms.service.ProcessLocationService;
import com.mt.roll.wms.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.groups.Default;
import java.util.List;

/**
 * @auther yanyang
 * @date 2022/2/24 16:39
 */

@RestController
@RequestMapping(CommonConstant.API_MODULE_WMS + "processlocation")
@Slf4j
@Api(value = "绑定工序库位信息", tags = "工序库位信息", hidden = false)

public class ProcessLocationController extends BaseController{

    @Autowired
    private ProcessLocationService processLocationService;

    @PostMapping(value = "page")
    @ApiOperation(value = "工序库位信息")
    private R<PageVo<ProcessLocationVo>> page(@Validated({PageGroup.class, Default.class}) @RequestBody ProcessLocationQueryParam processLocationQueryParam) {
        return processLocationService.page(processLocationQueryParam);
    }

    @PostMapping(value = "getById")
    @ApiOperation(value = "获取工序库位信息")
    private R<ProcessLocationVo> getById(@Validated @RequestBody IdParam idParam) {
        return processLocationService.getById(idParam);
    }

    @PostMapping(value = "add")
    @ApiOperation(value = "手动绑定工序库位")
    private R<IdVo> add(@Validated({AddGroup.class, Default.class}) @RequestBody ProcessLocationParam processLocationParam) {
        return processLocationService.add(processLocationParam);
    }

    @PostMapping(value = "update")
    @ApiOperation(value = "更新工序库位信息")
    private R<IdVo> update(@Validated({UpdateGroup.class, Default.class}) @RequestBody ProcessLocationParam  processLocationParam) {
        return processLocationService.update(processLocationParam);
    }

    @PostMapping(value = "delete")
    @ApiOperation(value = "删除工序库位信息")
    private R<IdVo> delete(@Validated @RequestBody IdParam idParam) {
        return processLocationService.delete(idParam);
    }



    @PostMapping(value = "workSequenList")
    @ApiOperation(value = "获取工序id列表")
    private R<List<WorkSequenceVo>> workSequenList(){
        return processLocationService.workSequenList();
    }

    @PostMapping(value = "locationList")
    @ApiOperation(value = "获取库位id列表")
    private R<List<LocationListVo>> locationList(){
        return processLocationService.locationList();
    }

    @PostMapping(value = "portAttrList")
    @ApiOperation(value = "获取库位属性id列表，关联数据字典")
    private R<List<SysDictDataVo>> portAttrList() { return processLocationService.portAttrList(); }

    @PostMapping(value = "batchList")
    @ApiOperation(value = "批量上架")
    private R<IdVo> processlocation(@Validated @RequestBody ProcessLocationListParam processLocationListParam) {
        return processLocationService.processlocation(processLocationListParam);
    }

    @PostMapping(value = "locationByProcess")
    @ApiOperation(value = "获取工序关联库位信息")
    private R<PageVo<AreaLocationVo>> locationByProcess(@Validated({PageGroup.class, Default.class}) @RequestBody ProcessQueryParam processQueryParam) {
        return processLocationService.locationByProcess(processQueryParam);
    }
}
